#pragma once

#include <QWidget>
#include <QStandardItemModel>
#include <QMap>
#include "QSocketClientManager.h"
namespace Ui { class QFileManagerWidget; };
class QFileItem;
class QFileManagerWidget : public QWidget
{
	Q_OBJECT
	friend class QMainControllerWindow;
public:
	enum QFileItemType {
		ITEM_DES_LOCAL = 0x200,
		ITEM_DES_HOST = 0x201,
		ITEM_LOCAL = 0x300,
		ITEM_HOST = 0x301,
		ITEM_LOCAL_FILE = 0x401,
		ITEM_HOST_FILE = 0x402
	};
	enum QFileType {
		FILE_DIR = 0x500,
		FILE_EXE = 0x501
	};
	QFileManagerWidget(QWidget *parent = Q_NULLPTR);
	~QFileManagerWidget();
	void OnlineHost(QSOCKETCLIENT& qSocketClient);
	void OfflineHost(QSOCKETCLIENT& qSocketClient);
	QSOCKETCLIENT GetCurrentSocketClient();
private:
	Ui::QFileManagerWidget *ui;
	QStandardItemModel m_qModel;
	QMap<QString, QSOCKETCLIENT> m_qClientMap;
private:
	void InitView();
	QFileItem* GetHostRootItem();
	QFileItem* FindHostItem(QString hardDiskSerialNumber, QString ip);
	QFileItem* FindHostItem(int id);
protected:
	void paintEvent(QPaintEvent* event);
};
